<?php

use app\cms\model\Pages AS PagesModel;

if(!function_exists('get_total_money')){
    /**
     * 统计每节的总共费用
     * @param array $info
     * @return string
     */
    function get_total_money($info=[]){
        $array = [];
        if($info['mid']==4){
            $array = is_array($info['voice_url'])?$info['voice_url']:json_decode($info['voice_url'],true);
        }elseif($info['mid']==3){
            $array = is_array($info['mv_url'])?$info['mv_url']:json_decode($info['mv_url'],true);
        }
        $total_money = 0;
        foreach ($array AS $rs){
            $rs['money']>0 && $total_money += $rs['money'];
        }
        return number_format($total_money,2);
    }    
}

if(!function_exists('get_content_pages')){
    /**
     * 获取文章模型的分页数据
     * @param number $aid
     * @return array
     */
    function get_content_pages($aid=0){        
        return PagesModel::get_all($aid);
    }
}